<template>
    <div class="mydiscover">
        <Top title="我的足迹" iconShow='1'>
        </Top>
        <tab :line-width="1" :custom-bar-width="getBarWidth" bar-active-color="#30ccdb" active-color="#30ccdb">
            <tab-item :selected="index==0" @on-item-click="onItemClick">产品
                <div></div>
            </tab-item>
            <tab-item :selected="index==1" @on-item-click="onItemClick">资讯
                 <div></div>
            </tab-item>
            <tab-item :selected="index==2" @on-item-click="onItemClick">帖子</tab-item>
        </tab>
        <router-view></router-view>
    </div>
</template>
<script>
import Top from '../../../components/Header'
import { Tab, TabItem } from 'vux'
export default {
    name: 'mydiscover',
    data() {
        return {
            getBarWidth: function() {  //表示的是vux的tab切换组件的宽的样式
                return 52 + 'px'
            },
            //selected: 0,
            index: 0
        }
    },
    mounted() {
        document.setTitle('我的发现');
        this.judgePage();
        //this.$router.push({ path: '/main/mine/mydiscover/Product' }); //页面一加载就跳转到这里去
    },
    watch: {
        $route() {
            this.judgePage()
        }
    },
    methods: {
        onItemClick(index) {   //点击用来切换路由 ，author:li
            if (index == 0) {
                this.$router.push({ path: '/main/mine/mydiscover/Product' });
            } else if(index==1){
                this.$router.push({ path: '/main/mine/mydiscover/Zixun' });
            }else{
                 this.$router.push({ path: '/main/mine/mydiscover/Tiezi' });
            }
        },
        judgePage() {  
            var hash = window.location.href.split('/').pop(); //表示转化成数组，然后删除最后一个元素，切返回最后一个元素的值 ,author:li
            console.log(hash);
            if (hash == 'Tiezi') {
                this.index = 2;
            } else if (hash == 'Zixun') {
                this.index = 1;
            }else if(hash=='Product'){
                 this.index = 0;
            }
        }
    },
    components: { Top, Tab, TabItem }
}
</script>
<style lang="scss" >
@import "../../../scss/variable/base.scss";
.mydiscover {
    .icon-edit{
        float: right;
    }
    .vux-tab {
        margin-top: 1.2rem !important;
        height: 1.4rem;
        font-weight: bold;
        position: fixed;
        left: 0;
        top: 0rem;
        z-index: 3;
        width: 100%;
        &-item {
            position: relative;
            font-size: 0.4rem !important;
            line-height: 1.4rem !important;
            div {

                width: 1px;
                background: $borderColor;
                top: 0.5rem;
                position: absolute;
                right: 0;
                height: 18px;
            }
        }
        .vux-tab-selected {
            font-weight: bold;
        }
    }


    &-content-informodal {
        margin-top: 1.2rem;
        width: 100%;
        height: 9.85rem;
        background: #fff;
        box-sizing: border-box;
        padding: 0 0.4rem;
        &-item {
            width: 100%;
            height: 3.07rem;
            box-sizing: border-box;
            padding-top: 0.42rem;
            display: flex;
            &-img {
                width: 3.6rem;
                height: 100%;
                background: url('../../../assets/selected1.png');
                border-radius: 0.12rem;
            }
            &-detail {
                box-sizing: border-box;
                padding: 0 0.27rem;
                width: 5.6rem;
                height: 100%;
                text-align: left;
                h4 {
                    font-size: 0.38rem;
                    height: 0.66rem;
                    line-height: 0.66rem;
                }
                span {
                    display: block;
                    height: 0.48rem;
                    line-height: 0.48rem;
                }
                div {
                    margin-top: 0.2rem;
                    line-height: 0.48rem;
                    font-size: 0.3rem;
                    height: 0.96rem;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    display: -webkit-box;
                    -webkit-line-clamp: 2;
                    -webkit-box-orient: vertical;
                }
            }
        }
    }
}
</style>


